
const TMDB = require('../utils/media-netdata/tmdb')
const logger = require('../utils/console-logger')

// 获取TMDb信息
async function findMetaInfo(query, mediaType) {
    logger.info('获取TMDb信息:', query, mediaType)
    let tmdbInfo = [];
    if (query && query.name) {
        const { name, year, season } = query;
        if (name) {
            if (mediaType === 'movie') {
                tmdbInfo = await TMDB.searchMovie(name, year);
            } else if (mediaType === 'tv') {
                tmdbInfo = await TMDB.searchTv(name, year);
            } else {
                tmdbInfo = await TMDB.search(name);
            }
            // console.log('tmdbInfo: ', tmdbInfo);
        }
    }
    return tmdbInfo;
}

module.exports = {
    findMetaInfo
}